package cn.xej.listener;

import cn.xej.pojo.User;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @Author alicat.xu
 * @Date 2021/10/20 1:43 下午
 */
@Component
public class FanoutListener {

    /**
     * msg： 表示消息里的参数
     * message: 表示消息体内容
     */
//    @RabbitListener(bindings = @QueueBinding(value = @Queue("queue.operate.test1"), exchange = @Exchange(type = ExchangeTypes.FANOUT,value = "exchange.fanout.test1")))
    public void fanoutStringEvent(String msg, Message message){
        System.out.println(msg+"   "+message);
    }

    @RabbitListener(queues = {"queue.operate.test1"})
    public void fanoutUserEvent(User msg, Message message){
        System.out.println(msg+"  "+message);
    }

}
